Skip to content

feat: gcp pubsub admin endpoints#4957

Open
ojproductions wants to merge 60 commits into
mainfrom
onzia/gcp-pubsub-admin-endpoints
Open

feat: gcp pubsub admin endpoints#4957
ojproductions wants to merge 60 commits into
mainfrom
onzia/gcp-pubsub-admin-endpoints

Conversation

@ojproductions

@ojproductions ojproductions commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Implements instrumentation for admin endpoints across v1 and v2 listed in the tables below

Common Span Tags (All Admin Operations)

All admin operations are traced via TraceAdmin in contrib/cloud.google.com/go/pubsubtrace/tracing.go and share these tags:

Tag Value Notes
span.type worker ext.SpanTypeWorker
span.kind client ext.SpanKindClient
messaging.system googlepubsub ext.MessagingSystemGCPPubsub
component Package name cloud.google.com/go/pubsub.v1 (v1) or cloud.google.com/go/pubsub.v2 (v2)
pubsub.method Operation name e.g. "CreateTopic", "DeleteSubscription"
resource.name "<method> <resourcePath>" Falls back to just <method> if path is empty
gcloud.project_id Extracted from resource path Only set when path starts with "projects/"
Measured true Always measured — not configurable via WithMeasured()
Span name requestSpanName Derived from instr.OperationName(ComponentClient, nil)

V1 vs V2 Client Type Mapping

Operation Category V1 Client V2 Client
Topic operations PublisherClient (cloud.google.com/go/pubsub/apiv1) TopicAdminClient (cloud.google.com/go/pubsub/v2/apiv1)
Subscription + snapshot operations SubscriberClient (cloud.google.com/go/pubsub/apiv1) SubscriptionAdminClient (cloud.google.com/go/pubsub/v2/apiv1)
Schema operations SchemaClient (cloud.google.com/go/pubsub/apiv1) SchemaClient (cloud.google.com/go/pubsub/v2/apiv1)

Topic Operations

Operation pubsub.method Resource path source gcloud.project_id set? V1 tracer helper V2 tracer helper
CreateTopic "CreateTopic" req.GetName() Yes (topic path) TraceCreateTopicV1 TraceCreateTopic
UpdateTopic "UpdateTopic" req.GetTopic().GetName() Yes (topic path) TraceUpdateTopicV1 TraceUpdateTopic
GetTopic "GetTopic" req.GetTopic() Yes (topic path) TraceGetTopicV1 TraceGetTopic
ListTopics "ListTopics" req.GetProject() Yes ("projects/...") TraceListTopicsV1 TraceListTopics
ListTopicSubscriptions "ListTopicSubscriptions" req.GetTopic() Yes (topic path) TraceListTopicSubscriptionsV1 TraceListTopicSubscriptions
ListTopicSnapshots "ListTopicSnapshots" req.GetTopic() Yes (topic path) TraceListTopicSnapshotsV1 TraceListTopicSnapshots
DeleteTopic "DeleteTopic" req.GetTopic() Yes (topic path) TraceDeleteTopicV1 TraceDeleteTopic
DetachSubscription "DetachSubscription" req.GetSubscription() Yes (subscription path) TraceDetachSubscriptionV1 TraceDetachSubscription

Subscription Operations

Operation pubsub.method Resource path source gcloud.project_id set? V1 tracer helper V2 tracer helper
CreateSubscription "CreateSubscription" req.GetName() Yes (sub path) TraceCreateSubscriptionV1 TraceCreateSubscription
GetSubscription "GetSubscription" req.GetSubscription() Yes (sub path) TraceGetSubscriptionV1 TraceGetSubscription
UpdateSubscription "UpdateSubscription" req.GetSubscription().GetName() Yes (sub path) TraceUpdateSubscriptionV1 TraceUpdateSubscription
ListSubscriptions "ListSubscriptions" req.GetProject() Yes ("projects/...") TraceListSubscriptionsV1 TraceListSubscriptions
DeleteSubscription "DeleteSubscription" req.GetSubscription() Yes (sub path) TraceDeleteSubscriptionV1 TraceDeleteSubscription
ModifyPushConfig "ModifyPushConfig" req.GetSubscription() Yes (sub path) TraceModifyPushConfigV1 TraceModifyPushConfig
Seek "Seek" req.GetSubscription() Yes (sub path) TraceSeekV1 TraceSeek

Snapshot Operations

Operation pubsub.method Resource path source gcloud.project_id set? V1 tracer helper V2 tracer helper
GetSnapshot "GetSnapshot" req.GetSnapshot() Yes (snapshot path) TraceGetSnapshotV1 TraceGetSnapshot
ListSnapshots "ListSnapshots" req.GetProject() Yes ("projects/...") TraceListSnapshotsV1 TraceListSnapshots
CreateSnapshot "CreateSnapshot" req.GetName() Yes (snapshot path) TraceCreateSnapshotV1 TraceCreateSnapshot
UpdateSnapshot "UpdateSnapshot" req.GetSnapshot().GetName() Yes (snapshot path) TraceUpdateSnapshotV1 TraceUpdateSnapshot
DeleteSnapshot "DeleteSnapshot" req.GetSnapshot() Yes (snapshot path) TraceDeleteSnapshotV1 TraceDeleteSnapshot

Schema Operations

Operation pubsub.method Resource path source gcloud.project_id set? V1 tracer helper V2 tracer helper
CreateSchema "CreateSchema" req.GetParent() Yes ("projects/...") TraceCreateSchemaV1 TraceCreateSchema
GetSchema "GetSchema" req.GetName() Yes (schema path) TraceGetSchemaV1 TraceGetSchema
ListSchemas "ListSchemas" req.GetParent() Yes ("projects/...") TraceListSchemasV1 TraceListSchemas
ListSchemaRevisions "ListSchemaRevisions" req.GetName() Yes (schema path) TraceListSchemaRevisionsV1 TraceListSchemaRevisions
CommitSchema "CommitSchema" req.GetName() Yes (schema path) TraceCommitSchemaV1 TraceCommitSchema
RollbackSchema "RollbackSchema" req.GetName() Yes (schema path) TraceRollbackSchemaV1 TraceRollbackSchema
DeleteSchemaRevision "DeleteSchemaRevision" req.GetName() Yes (schema path) TraceDeleteSchemaRevisionV1 TraceDeleteSchemaRevision
DeleteSchema "DeleteSchema" req.GetName() Yes (schema path) TraceDeleteSchemaV1 TraceDeleteSchema
ValidateSchema "ValidateSchema" req.GetParent() Yes ("projects/...") TraceValidateSchemaV1 TraceValidateSchema
ValidateMessage "ValidateMessage" req.GetParent() Yes ("projects/...") TraceValidateMessageV1 TraceValidateMessage

Motivation

APMSVLS-536
view @pablomartinezbernardo's python implementation here

Questions:
Should we be instrumenting v1? Its being deprecated by google

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • All generated files are up to date. You can check this by running make generate locally.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running make fix-modules locally.

Unsure? Have a question? Request a review!

Copilot AI review requested due to automatic review settings July 22, 2026 01:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 19 changed files in this pull request and generated 4 comments.

Files not reviewed (2)
  • internal/orchestrion/_integration/gcp_pubsub.v1/generated_test.go: Generated file
  • internal/orchestrion/_integration/gcp_pubsub.v2/generated_test.go: Generated file
Comments suppressed due to low confidence (1)

contrib/cloud.google.com/go/pubsubtrace/tracing.go:221

  • The comment above projectIDFromResourceName is now misleading: the implementation extracts the project ID from any resource name starting with "projects/" (including bare "projects/{project}" used by admin operations), not just topics/subscriptions.
// extracts the GCP project ID from a Pubsub resource name of the form
// "projects/{project}/topics/{topic}" or "projects/{project}/subscriptions/{subscription}"

Comment thread internal/orchestrion/_integration/gcp_pubsub.v2/gcp_pubsub_admin.go
Comment thread internal/orchestrion/_integration/gcp_pubsub.v1/gcp_pubsub_admin.go
Comment thread contrib/cloud.google.com/go/pubsubtrace/admin.go Outdated
Comment thread contrib/cloud.google.com/go/pubsubtrace/admin_v1.go Outdated
Copilot AI review requested due to automatic review settings July 22, 2026 13:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 19 changed files in this pull request and generated 4 comments.

Files not reviewed (2)
  • internal/orchestrion/_integration/gcp_pubsub.v1/generated_test.go: Generated file
  • internal/orchestrion/_integration/gcp_pubsub.v2/generated_test.go: Generated file
Comments suppressed due to low confidence (3)

internal/orchestrion/_integration/gcp_pubsub.v2/gcp_pubsub_admin.go:122

  • adminTrace hard-codes the project ID tag to testProject, but the resource paths are built from b.projectID (from the container settings). If these ever differ, traces will be inconsistent.
			ext.GCPProjectID: testProject,

internal/orchestrion/_integration/gcp_pubsub.v1/gcp_pubsub_admin.go:123

  • adminTrace hard-codes the project ID tag to adminProject, but the resource paths are built from b.projectID (from the container settings). If these ever differ, traces will be inconsistent.
			ext.GCPProjectID: adminProject,

contrib/cloud.google.com/go/pubsubtrace/tracing.go:221

  • This comment has an unmatched quote and an incomplete example ("projects/{project}. ..."), which makes it unclear what formats are supported.
// extracts the GCP project ID from a Pubsub resource name starting with
// "projects/{project}. e.g. schemas, snapshots, topics and subscriptions

Comment thread internal/orchestrion/_integration/gcp_pubsub.v2/gcp_pubsub_admin.go
Comment thread internal/orchestrion/_integration/gcp_pubsub.v1/gcp_pubsub_admin.go
Comment thread contrib/cloud.google.com/go/pubsubtrace/admin.go Outdated
Comment thread contrib/cloud.google.com/go/pubsubtrace/tracing.go
Copilot AI review requested due to automatic review settings July 22, 2026 15:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 19 changed files in this pull request and generated 2 comments.

Files not reviewed (2)
  • internal/orchestrion/_integration/gcp_pubsub.v1/generated_test.go: Generated file
  • internal/orchestrion/_integration/gcp_pubsub.v2/generated_test.go: Generated file

Comment thread contrib/cloud.google.com/go/pubsubtrace/tracing.go
Comment thread contrib/cloud.google.com/go/pubsubtrace/admin_interceptor.go

@rarguelloF rarguelloF left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed during our meeting, let's leave the REST client for a follow-up PR. Nice work! @ojproductions

@ojproductions

Copy link
Copy Markdown
Contributor Author

/merge -m squash

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 23, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-23 20:03:04 UTC ℹ️ Start processing command /merge -m squash


2026-07-23 20:03:14 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-07-24 00:08:11 UTC ⚠️ MergeQueue: This merge request was unqueued

devflow unqueued this merge request: It did not become mergeable within the expected time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apm:ecosystem contrib/* related feature requests or bugs mergequeue-status: removed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants